import { reactive } from "vue";
import { io } from "socket.io-client";

export const state = reactive({
  connected: false,
  fooEvents: [],
  barEvents: []
});

// "undefined" means the URL will be computed from the `window.location` object
// const URL = process.env.NODE_ENV === "production" ? undefined : "http://localhost:3000";
const URL = "ws://127.0.0.1:17935";

export const socket = io(URL, {
  reconnection: false
});

socket.on("connect", () => {
  state.connected = true;
  console.log("connect");
});

socket.on("disconnect", () => {
  state.connected = false;
});
